package com.iflytek.sbd.demo.lambda;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @program: sbd
 * @description: 测试lambda的map
 * @author: 陈英俊
 * @create: 2022-01-20 12:20
 */
public class MapLambdaDemo {


    public static void main(String[] args) {

        ArrayList<Student> list = new ArrayList<>();
        for (int i = 1; i <= 50; i++) {
            Student student = new Student();
            student.setName("陈" + i);
            student.setAge(i);
            list.add(student);
        }

        List<Info> infos = list.stream().map(student -> {
            Info info = new Info();
            info.setMessage(student.getName());
            return info;
        }).collect(Collectors.toList());

        System.out.println(infos);

        ArrayList<Info> result2 = new ArrayList<>();
        list.forEach(student -> {
            Info info = new Info();
            info.setMessage(student.getName());
            result2.add(info);
        });
    }
}